#ifndef COMMONS_H_
#define COMMONS_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../config.h"
#include "../arpamessage.h"
#include "errors.h"


#ifdef _WIN32
#include <Windows.h>

#else
#include <sys/types.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <sys/resource.h>
#include <sys/signal.h>
#include <regex.h>
#endif

#define BUF_SIZE 64;

typedef enum modes {READ,WRITE, WTRUNC} MODE;
typedef enum datatype{
	INT_TYPE, 
	LONG_TIPE,
	CHAR_TYPE, 
	FLOAT_TYPE, 
	DOUBLE_TYPE, 
	UINT_TYPE,
	ULONG_TYPE,
	PINT_TYPE,
	PLONG_TIPE,
	PCHAR_TYPE, 
	PFLOAT_TYPE, 
	PDOUBLE_TYPE, 
	PVOID_TYPE,
	CNF_PTR_TYPE,
	SMTPSESSION_TYPE,
	MAILCMD_TYPE,
	LPDWORD_TYPE,
	PREGEL_TYPE,
	ARPAMSG_TYPE,
	MBXSEM_TYPE,
	PMBXSEM_TYPE,
	PPMBXSEM_TYPE,

} TYPE;

int isNull(void *);
long decodeMode(MODE);
void *openFile(char *,MODE, int);
void *createFile(char *,MODE, int);
void *openOrCreateFile(char *,MODE, int *);
void closeFile(void *);
char *readFileLine(void *, int *);
char *readAllFile(void *);
char *readFileBlock(void *, unsigned long *);
void writeFile(void *, char *);
void createDir(char *);
void *getMemory(int ,TYPE);
int match_regex (regex_t * , const char * , const char *);
int countFileBytes(void *);
int isStringInSet(char**, char*);
char *readFileByte(void *, unsigned long *);
char *substituteString(char *, char *, char *);
char *removeAngParenthesys (char []);


#endif /* UTILS_H_ */
